﻿@model MobileTouchCafe.Models.Md_BanHang

@{
    ViewBag.Title = "Detail";
}

<script src="@Url.Content("~/Scripts/table_detail.js")" type="text/javascript"></script>

<script>
    $('#f_date').datetimepicker({
        timeText: '',
	    hourText: 'Giờ',
	    minuteText: 'Phút',
	    secondText: 'Giây',
	    currentText: 'Hiện tại',
	    closeText: 'Đóng'
	});

	$('#summary_dis_percent').spinner({ step: 5,
	    stop: function (event, ui) { summaryTotal(); }
	});
	$('#summary_dis_percent').css('width', '30px');
</script>

<div id="detail_data" saleid="@Model.BanHang.IdBanHang" tblid="@Model.BanHang.IdBan">
 
 <div id="message_notify" style="display:none;width:400px;height:250px;background-color:#fff;">
        <p>Thông báo :</p>
        <p id="message_notify_msg"></p>
        <p></p>
        <input type="button" value="Đồng ý" onclick="close_notify();"/>
 </div>

    <div id="dtl_top_menu">
        <span><input value="@Model.BanHang.Ngay.ToString("dd/MM/yyyy HH:mm")" style="font-size:18px;margin-top:6px;width:160px;" id="f_date" class="input_text datepicker" /></span>
        <span id="btn_new" class="btn">Tạo mới</span>
        <span id="btn_save" class="btn">Lưu</span>
        <span id="btn_print" class="btn">In hóa đơn</span>
        <span id="btn_del" class="btn">Xóa</span>
        <span id="btn_home" class="btn">Trở về</span>
    </div>
    <div id="dtl_group">Thông tin chi tiết
        <div id="group_split_table"></div>
    </div>
    <div id="dtl_summary">
        <table>
            <tr>
                <td style="padding-left:20px; width:150px;" class="item_detail">
                    <img src="/Content/Themes/Fontend/Images/tbl2.png" />
                    <span id="detail_table_name">000</span>
                </td>
                <td id="summay_data">
                
                    <table>
                        <tr>
                            <td style="width:116px;">Tổng tiền</td>
                            <td><input id="summary_sub_total" style="width:140px;" type="text" value="@((Model.BanHang==null)? "0" : Model.BanHang.ThanhTien.ToString("n2"))" readonly/></td>
                            <td>Chiết khấu</td>
                            <td><input type="text" id="summary_dis_percent" value="@((Model.BanHang==null)? 0 : Model.BanHang.PT_CK)"/></td>
                            <td><input type="text" id="summary_dis_value" value="@((Model.BanHang==null)? "0" : Model.BanHang.Tien_CK.ToString("n2"))" readonly/></td>
                        </tr>
                    </table>
                    <table>
                        <tr>
                            <td style="width:144px;"></td>
                            <td style="color:red;">Tổng tiền phải thanh toán</td>
                            <td><input id="summary_total" style="width:270px;" type="text" value="@((Model.BanHang==null)? "0" : Model.BanHang.TongTien.ToString("n2"))" readonly/></td>
                        </tr>
                    </table>
                    <table>
                        <tr>
                            <td>Tiền khách trả</td>
                            <td><input id="summary_payment" style="width:140px;" type="text" value="@((Model.BanHang == null)? "0" : Model.BanHang.KhachTra.ToString("n2"))" /></td>
                            <td>Tiền trả lại</td>
                            <td><input id="summary_repay" style="width:270px;" type="text" value="" readonly/></td>
                        </tr>
                    </table>
                
                </td>
            </tr>
        </table>
        <table style="padding-top:10px;">
            <tr>
                <td style="width:284px;"></td>
                <td>
                <a href="#" onclick="Payment(50000);"> 50 </a> <span> - </span>
                <a href="#" onclick="Payment(100000);"> 100 </a> <span> - </span> 
                <a href="#" onclick="Payment(150000);"> 150 </a> <span> - </span> 
                <a href="#" onclick="Payment(200000);"> 200 </a>  <span> - </span>
                <a href="#" onclick="Payment(300000);"> 300 </a></td>
                <td style="width:180px;"></td>
                <td style="padding-left:20px;"><span id="btn_sprint" >In pha chế</span></td>
            </tr>
        </table>
        <table id="detail_list_menu" style="padding-top:10px;width:100%;overflow:scroll;"> <!-- Menu -->
            <tr style="background:#cecece;height:28px;">
                <td style="width:100px;">Mã</td>
                <td>Tên, mô tả</td>
                <td style="width:80px;">Đơn vị</td>
                <td style="width:100px;">Số lượng</td>
                <td style="width:110px;">Đơn giá</td>
                <td style="width:120px;">Tổng tiền</td>
                <td style="width:22px;"></td>
            </tr>
            
            @if (@Model.BanHang_HangHoa != null)
            {
                foreach (Entities.eBh_BanHang_HangHoa ct in @Model.BanHang_HangHoa)
                {
                    string id = "detail_row_qty_" + @ct.IdHangHoa.ToString();
                <tr value="@ct.IdHangHoa">
                    <td>@ct.HangHoa.MaHang</td>
                    <td class="itm_name_cell">@ct.HangHoa.TenHang</td>
                    <td class="itm_unit_id" value="@ct.DVT.IdDVT">@ct.DVT.TenDVT</td>
                    <td id='@id' class="qty_cell" onclick='ShowQtyChange(this);'>@ct.SoLuong</td>
                    <td class="price_cell">@ct.DonGia.ToString("n2")</td>
                    <td class="total_cell">@ct.TongTien.ToString("n2")</td>
                    <td onclick="remove_row_detail(this);" style="color:Red;">x</td>
                </tr> 
                }
            }
            
        </table> <!-- End Menu -->
        
    </div>
    <div id="qty_change" value = "0" elementid="">
        <div id="qty_change_input">
            <input id="input_text_change_qty" type="text" />
            <input id="input_btn_plus_qty" type="button" value="+"/>
            <input id="input_btn_minus_qty" type="button" value="-"/>
            <input id="input_btn_accept_qty" style="width:80px;" type="button" value="Ok"/>
        </div>
    </div>
    <div id="message_remove_row" value="0" style="display:none;width:400px;height:250px;background-color:#fff;">
        <p>Bạn có chắc chắn muốn hủy thực đơn :</p>
        <p id="remove_row_itm_name_msg"></p>
        <p>Ra khỏi bàn sô ??? hay không ?</p>
        <input type="button" value="Đồng ý" onclick="close_message('1');"/>
        <input type="button" value="Hủy bỏ" onclick="close_message('0');"/>
    </div>
</div>
<div id="detail_left_menu">
    <div id="lf_top">
        <span>Thực đơn</span>
    </div>

    <div id="lf_body">
            <div id="lf_menu">
                <table style="width:100%;height:100%;">
                    <tr>
                        <td style="width:100px;"> <!-- Group Menu -->
                            <div id="lf_menu_grp">
                                @if (Model.NhomHang != null)
                                {
                                    foreach (Entities.eL_NhomHang nh in Model.NhomHang)
                                    {
                                        <div class="lf_menu_grp_item" value="@nh.IdNhom">
                                            <img src="data:image/jpg;base64,@(Convert.ToBase64String(nh.HinhAnh))" alt="@nh.TenNhom" />
                                        </div>
                                    } 
                                } 
                            </div>

                        </td> 
                        <td> <!-- Detail Menu -->
                            <div id="menu_detail_item">
                                <div style="width:100%;height:36px;background:#ccc;">
                                    <table>
                                        <tr>
                                            <td><img src="/Content/Themes/Fontend/Images/Buttons/all_list.png" /></td>
                                            <td><input id="serach_items" type="text"" /></td>
                                            <td><img src="/Content/Themes/Fontend/Images/Buttons/add.png" onclick="addItem();"/></td>
                                        </tr>
                                    </table>            
                                </div>
                                <table >
                                    <tr>
                                        <td>
                                            <table id="lst_items">
                                                @if (Model.HangHoa != null)
                                                {
                                                    foreach (Entities.eL_HangHoa hh in Model.HangHoa)
                                                    {
                                                        <tr class="row_item" value="@hh.IdHangHoa" sel="0" 
                                                            colls="@hh.MaHang#@hh.TenHang#@hh.IdDVT#@hh.TenDVT#@hh.DonGia">
                                                            <td style="width:32px;"><input type="checkbox"/></td>
                                                            <td>@hh.TenHang</td>
                                                            <td>
                                                                @if(hh.HinhAnh!=null && hh.HinhAnh.Length>0)
                                                                {
                                                                    <img src="data:image/jpg;base64,@(Convert.ToBase64String(hh.HinhAnh))" />
                                                                }
                                                            </td>
                                                            <td class="f_groupid" style="display:none;">@hh.IdNhom</td>
                                                        </tr> 
                                                    } 
                                                }
                                            </table>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </td>
                    </tr>
                </table>
            </div>
    </div>
</div>

<div id="find_tbl_container">
    <div id="f_tbl_loctaion">
        <table id="tbl_f_loaction">
            <tr>
                
            </tr>
        </table>
        <input type="text" id="f_find_item" />
        <span id="f_itm_selected" value="0">--?--</span>
        <input type="button" value="Đồng ý"  onclick="tbl_sel_ms_accept();"/>
    </div>
</div>

<div id="tbl_ms_detail">
    <div id="tbl_ms_dtl_tbl">
        <div id="tbl_ms_dtl_tbl_f">
            <img src='/Content/Themes/Fontend/Images/tbl2.png'/><span id="table_move_from">101</span>
        </div>
        <img src='/Content/Themes/Fontend/Images/arr_down.png' style="margin-left:34px;"/>
        <div id="tbl_ms_dtl_tbl_t">
            <img src='/Content/Themes/Fontend/Images/tbl2.png'/><span id="table_move_to">102</span>
        </div>
    </div>
    <div id="tbl_ms_dtl_ctx">
        <div id="tbl_ms_dtl_ops">
            <div id="tbl_ms_dtl_op1" value="1">
                <p class="radio_button" def="1" onclick="tbl_ms_dtl_op1_click(1);"><span class="radio rdo_checked"></span> <span class="radio_text">Chuyển/ tách bàn</span></p>
                <p class="radio_button" def="2" onclick="tbl_ms_dtl_op1_click(2);""><span class="radio rdo_normal"></span> <span class="radio_text">Gộp bàn</span></p>
            </div>
            <div id="tbl_ms_dtl_op2" value="0" style="display:none;">
                <p class="radio_button" def="1"><span class="radio rdo_normal"></span> <span class="radio_text">Gộp bill - giữ bàn</span></p>
                <p class="radio_button" def="2"><span class="radio rdo_normal"></span> <span class="radio_text">Gộp bill - gộp bàn</span></p>
            </div>
            <div id="tbl_ms_dtl_op3" value="1">
                <p id="tlb_ms_dtl_all_menu" class="radio_button" def="1"><span class="radio rdo_checked"></span> <span class="radio_text">Tất cả thực đơn</span></p>
                <p id="tbl_ms_dtl_sel_menu" class="radio_button" def="2"><span class="radio rdo_normal"></span> <span class="radio_text">Chọn thực đơn</span></p>
            </div>
        </div>
        <div id="tbl_ms_dtl_menu">
            <table id="tbl_ms_dtl_itms" style="width:98%;margin-top:20px;">
                <tr>
                    <th>Tên hàng</th>
                    <th style="width:100px;">ĐVT</th>
                    <th style="width:120px;">Số lượng</th>
                </tr>
            </table>
        </div>
    </div>
</div>
